
import Widget from '@/low-code/widget/index'
import Parse from '@/low-code/parse/index.vue'
import dropWrap from '@/low-code/components/drop-wrap/index.vue'
import { Store } from "@/low-code/utils/store"
import { Pipe } from "@/low-code/utils/pipe"
import { handleStack, restoreHandleStack } from "@/low-code/utils/stack"
// import "../basis-components/styles/index.scss"
import "@/low-code/directive/drop-wrap-blank.js"

const install = function (Vue, opts = {}) {

  if (install.installed) return;

  let {components,axios,prefixUrl}=opts
  /**组件注册 */
  if (!components) {
    throw new Error("请传入外部components")
  }
  components&&(()=>{
    for (let key in components) {
      Vue.component(key, components[key]);
    }
  })()
  /**
   * 挂载外部封装的axios
   */
  if (!axios) {
    throw new Error("请传入外部axios")
  }
  Store.axios = axios
  Store.prefixUrl = prefixUrl
  Store.messagePool=new Pipe()

  Vue.component("widget", Widget)
  Vue.component("dropWrap", dropWrap)
  Vue.component("lowParse", Parse)
  Vue.prototype.$handleStack = handleStack;
  Vue.prototype.$restoreHandleStack = restoreHandleStack;

}

export default {
  Store,
  install,
  messagePool:Store.messagePool
}